int phys_proc_id[NR_CPUS];
unsigned long loops_per_jiffy = (1<<12); // from linux/init/main.c
-unsigned int watchdog_on = 0; // from arch/x86/nmi.c ?!?
-
void unw_init(void) { printf("unw_init() skipped (NEED FOR KERNEL UNWIND)\n"); }
void ia64_mca_init(void) { printf("ia64_mca_init() skipped (Machine check abort handling)\n"); }
void ia64_mca_cpu_init(void *x) { }
static atomic_t xendbg_running = ATOMIC_INIT(1);
static char recv_buf[4096];
unsigned flags;
- unsigned old_watchdog;
if (xdb_ctx.serhnd < 0) {
dbg_printk("Debugger not ready yet.\n");
interrupts while we're here. */
local_irq_save(flags);
- old_watchdog = watchdog_on;
- watchdog_on = 0;
+ watchdog_disable();
/* Shouldn't really do this, but otherwise we stop for no
obvious reason, which is Bad */
ASSERT(!local_irq_is_enabled());
}
}
- watchdog_on = old_watchdog;
+ watchdog_enable();
atomic_inc(&xendbg_running);
local_irq_restore(flags);
return 0;
void machine_halt(void)
{
- watchdog_on = 0;
+ watchdog_disable();
smp_call_function(__machine_halt, NULL, 1, 0);
__machine_halt(NULL);
}
#include <asm/debugger.h>
unsigned int nmi_watchdog = NMI_NONE;
-unsigned int watchdog_on = 0;
static unsigned int nmi_hz = HZ;
unsigned int nmi_perfctr_msr; /* the MSR to reset in NMI handler */
last_irq_sums [NR_CPUS],
alert_counter [NR_CPUS];
+static spinlock_t watchdog_lock = SPIN_LOCK_UNLOCKED;
+static unsigned int watchdog_disable_count = 1;
+static unsigned int watchdog_on;
+
+void watchdog_disable(void)
+{
+ unsigned long flags;
+ spin_lock_irqsave(&watchdog_lock, flags);
+ if ( watchdog_disable_count++ == 0 )
+ watchdog_on = 0;
+ spin_unlock_irqrestore(&watchdog_lock, flags);
+}
+
+void watchdog_enable(void)
+{
+ unsigned long flags;
+ spin_lock_irqsave(&watchdog_lock, flags);
+ if ( --watchdog_disable_count == 0 )
+ watchdog_on = 1;
+ spin_unlock_irqrestore(&watchdog_lock, flags);
+}
+
void touch_nmi_watchdog (void)
{
int i;
while ( wait_init_idle != 0 )
cpu_relax();
- watchdog_on = 1;
+ watchdog_enable();
+
#ifdef __x86_64__ /* x86_32 uses low mappings when building DOM0. */
zap_low_mappings();
#endif
"machine check", "simd error"
};
- watchdog_on = 0;
+ watchdog_disable();
show_registers(regs);
struct tss_struct *tss = &doublefault_tss;
unsigned int cpu = ((tss->back_link>>3)-__FIRST_TSS_ENTRY)>>1;
- /* Disable the NMI watchdog. It's useless now. */
- watchdog_on = 0;
+ watchdog_disable();
console_force_unlock();
asmlinkage void double_fault(void);
asmlinkage void do_double_fault(struct cpu_user_regs *regs)
{
- /* Disable the NMI watchdog. It's useless now. */
- watchdog_on = 0;
+ watchdog_disable();
console_force_unlock();
unsigned long pfn, flags;
printk("Scrubbing Free RAM: ");
+ watchdog_disable();
for ( pfn = 0; pfn < (bitmap_size * 8); pfn++ )
{
- /* Every 100MB, print a progress dot and appease the watchdog. */
+ /* Every 100MB, print a progress dot. */
if ( (pfn % ((100*1024*1024)/PAGE_SIZE)) == 0 )
- {
printk(".");
- touch_nmi_watchdog();
- }
/* Quick lock-free check. */
if ( allocated_in_map(pfn) )
spin_unlock_irqrestore(&heap_lock, flags);
}
+ watchdog_enable();
printk("done.\n");
}
void debugtrace_dump(void)
{
- int _watchdog_on = watchdog_on;
unsigned long flags;
if ( (debugtrace_bytes == 0) || !debugtrace_used )
return;
- /* Watchdog can trigger if we print a really large buffer. */
- watchdog_on = 0;
+ watchdog_disable();
spin_lock_irqsave(&debugtrace_lock, flags);
spin_unlock_irqrestore(&debugtrace_lock, flags);
- watchdog_on = _watchdog_on;
+ watchdog_enable();
}
void debugtrace_printk(const char *fmt, ...)
__putstr("Reboot in five seconds...\n");
spin_unlock_irqrestore(&console_lock, flags);
- watchdog_on = 0;
+ watchdog_disable();
mdelay(5000);
machine_restart(0);
}
#define FASTCALL(x) x // see linux/include/linux/linkage.h
#define fastcall // " "
-#define touch_nmi_watchdog()
+#define watchdog_disable() ((void)0)
+#define watchdog_enable() ((void)0)
// from linux/include/linux/types.h
#define CLEAR_BITMAP(name,bits) \
memset(name, 0, BITS_TO_LONGS(bits)*sizeof(unsigned long))
// these declarations got moved at some point, find a better place for them
extern int opt_noht;
extern int ht_per_core;
-extern unsigned int watchdog_on;
// xen/include/asm/config.h
/******************************************************************************
extern void disable_timer_nmi_watchdog(void);
extern void enable_timer_nmi_watchdog(void);
extern void nmi_watchdog_tick (struct cpu_user_regs *regs);
-extern void touch_nmi_watchdog(void);
extern int APIC_init_uniprocessor (void);
extern void disable_APIC_timer(void);
extern void enable_APIC_timer(void);
-extern unsigned int watchdog_on;
extern int check_nmi_watchdog (void);
extern void enable_NMI_through_LVT0 (void * dummy);
+extern void watchdog_disable(void);
+extern void watchdog_enable(void);
+
extern unsigned int nmi_watchdog;
#define NMI_NONE 0
#define NMI_IO_APIC 1